class AlarmSrv {
    constructor(commonSrv) {
        "ngInject";
        this._commonSrv = commonSrv;
    }

    // 查询告警列表，包括查询告警详细都使用此方法
    getAlarmListOfK8s(page, para) {
        return this._commonSrv('get', '/ctg-imageconsole-web/alarm/queryAlarms', {
            perpage: page.perPage,
            page: page.currentPage,
            clusterCode: para.clusterInst && para.clusterInst.clusterCode,
            isactive: para.isactive,
            alertType: para.alertType,
            startTime: para.startTime && (~para.startTime.indexOf('-') ? new Date(para.startTime).getTime() : para.startTime),
            endTime: para.endTime && (~para.endTime.indexOf('-') ? new Date(para.endTime).getTime() : para.endTime)
        });
    }
    
    getHeadAlarmOfK8s(){
        return this._commonSrv('get', '/ctg-imageconsole-web/alarm/queryHeadK8sAlarms', {});
    }

    getAlertRules(page, filter){
        return this._commonSrv('get', '/ctg-imageconsole-web/alarm/queryAlertRules', {
            page: page.currentPage,
            perpage: 10,
            type: filter && filter.type,
            clusterCode : filter && filter.clusterCode
        });
    }

    getAlertTypes(filter){
        return this._commonSrv('get', '/ctg-imageconsole-web/alarm/queryAlertTypes', {
            clusterCode : filter.clusterCode
        });
    }

    editAlertRule(filter){
        return this._commonSrv('post', '/ctg-imageconsole-web/alarm/modifyAlertRule', {
            clusterCode : filter && filter.clusterCode,
            alertRuleDTO: filter && filter.alertRuleDTO
        });
    }

    deleteAlertRule(filter) {
        return this._commonSrv('post', '/ctg-imageconsole-web/alarm/deleteAlertRule', {
            clusterCode : filter && filter.clusterCode,
            alertRuleDTO : filter && filter.alertRuleDTO
        })
    }

    addAlertRule(filter){
        return this._commonSrv('post', '/ctg-imageconsole-web/alarm/addAlertRule', {
            clusterCode : filter && filter.clusterCode,
            alertRuleDTO: filter && filter.alertRuleDTO
        })
    }

    getAlertRuleDetail(filter) {
        return this._commonSrv('get', '/ctg-imageconsole-web/alarm/queryAlertRule', {
            clusterCode : filter.clusterCode,
            id:  filter.id
        })
    }

    //--------------------------------------------------Notification----------------------------------------------//

    getNotificationList(para){
        return this._commonSrv('get', '/ctg-imageconsole-web/systemNotice/queryNoticeList', {
            pageNum: para.pageNum,
            pageSize: 10,
            noticeState: '001'
        })
    }

    editNotice(id){
        return this._commonSrv('post', '/ctg-imageconsole-web/systemNotice/modifyNotice', {
            id: id,
            noticeState: '002'
        })
    }
}
export default AlarmSrv